/*
 * Copyright 2013-2019 Xia Jun(3979434@qq.com).
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 ***************************************************************************************
 *                                                                                     *
 *                        Website : http://www.farsunset.com                           *
 *                                                                                     *
 ***************************************************************************************
 */
package com.workcell.workdata.im.model.request;

import com.workcell.workdata.im.annotation.CreateAction;
import com.workcell.workdata.im.constant.MessageAction;
import com.workcell.workdata.im.constant.MessageFormat;
import com.workcell.workdata.im.entity.GroupMessage;
import com.workcell.workdata.im.entity.Message;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import javax.validation.constraints.NotNull;
import java.io.Serializable;

@ApiModel
public class GroupMessageRequest implements Serializable {

	@NotNull(message = "groupId不能为空",groups = CreateAction.class)
	@ApiModelProperty(value = "群ID")
	private Long groupId;

	@ApiModelProperty("标题")
	private String title;

	@ApiModelProperty("内容")
	private String content;

	@ApiModelProperty("附加信息")
	private String extra;

	@ApiModelProperty("格式")
	private Byte format = MessageFormat.TEXT;

	public Long getGroupId() {
		return groupId;
	}

	public void setGroupId(Long groupId) {
		this.groupId = groupId;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getExtra() {
		return extra;
	}

	public void setExtra(String extra) {
		this.extra = extra;
	}

	public Byte getFormat() {
		return format;
	}

	public void setFormat(Byte format) {
		this.format = format;
	}

	public Message ofMessage(){
		Message message = new GroupMessage();
		message.setReceiver(groupId);
		message.setAction(MessageAction.ACTION_3);
		message.setTitle(title);
		message.setContent(content);
		message.setExtra(extra);
		message.setFormat(format);
		return message;
	}

}
